package cc.rengu.redp.bizimpl.upmp.vo;

import io.swagger.annotations.ApiModelProperty;

public class OperationResult {
    public static final String SUCCESS = "100000";
    public static final String FAILURE = "999999";
    private String type;
    private String code;
    private String message;
    private Object data;
    private String redirect;

    public static OperationResult buildSuccessResult(String message, Object data) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.success, message, data);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildSuccessResult() {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.success, (String)null);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildSuccessResult(String message,String data) {//商户等级和商户名称
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.success, message,data);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildSuccessResult(Object data) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.success, "success", data);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildWarningResult(String message, Object data) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.warning, message, data);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildFailureResult(String message) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.failure, message);
        or.setCode("999999");
        return or;
    }

    public static OperationResult buildFailureResult(String message, Object data) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.failure, message, data);
        or.setCode("999999");
        return or;
    }

    public static OperationResult buildConfirmResult(String message, Object data) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.confirm, message, data);
        or.setCode("100000");
        return or;
    }

    public static OperationResult buildConfirmResult(String message) {
        OperationResult or = new OperationResult(OPERATION_RESULT_TYPE.confirm, message, (Object)null);
        or.setCode("100000");
        return or;
    }

    public OperationResult(OPERATION_RESULT_TYPE type, String message) {
        this.type = type.name();
        this.message = message;
    }

    public OperationResult(OPERATION_RESULT_TYPE type, String message, Object data) {
        this.type = type.name();
        this.message = message;
        this.data = data;
    }

    public OperationResult(OPERATION_RESULT_TYPE type, String message, String code, Object data) {
        this.type = type.name();
        this.message = message;
        this.data = data;
        this.code = code;
    }

    public OperationResult(OPERATION_RESULT_TYPE type, String message, String code, Object data, String redirect) {
        this.type = type.name();
        this.message = message;
        this.data = data;
        this.code = code;
        this.redirect = redirect;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return this.data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getRedirect() {
        return this.redirect;
    }

    public void setRedirect(String redirect) {
        this.redirect = redirect;
    }

    public static enum OPERATION_RESULT_TYPE {
        @ApiModelProperty(
            value = "成功,操作处理成功。前端一般是绿色的短暂气泡提示"
        )
        success,
        @ ApiModelProperty(
            value = "警告,偶尔用于标识业务处理基本完成，但是其中存在一些需要注意放在message或data中的提示信息。前端一般是黄色的气泡提示"
        )
        warning,
        @ ApiModelProperty(
            value = "失败,操作处理失败。前端一般是红色的长时间或需要用户主动关闭的气泡提示"
        )
        failure,
        @ ApiModelProperty(
            value = "确认,本次提交中止，反馈用户进行确认。前端一般会弹出一个供用户'确认'操作的对话框，然后用户主动确认之后会自动再次发起请求并跳过确认检查进行后续业务处理"
        )
        confirm;

        private OPERATION_RESULT_TYPE() {
        }
    }
}